using System;
using System.Diagnostics;
using System.Windows.Input;
using Rhizome.Model;
using Rhizome.Model.Validation;
using Rhizome.QuickStart.Elevator.Contract;
using Rhizome.QuickStart.Elevator.Model;

namespace Rhizome.QuickStart.Elevator.ViewModel
{
    public sealed class ElevatorViewModel : ViewModelBase<IElevator>
    {
        public ElevatorViewModel()
        {
#if !WINDOWS_PHONE
            StopCommand = new DelegateCommand(InvokeStopClick);
#endif
            Model = new ElevatorModel();

			var automaton = new Automaton {Plant = Model};
        	automaton.Validate();
        	automaton.Start();
        }

        public double Position
        {
            [DebuggerStepThrough]
            get { return Model.Position; }
        }

#if !WINDOWS_PHONE
        public ICommand StopCommand { get; private set; }
#endif

        public void InvokeStopClick()
        {
            Model.InvokeStopClick();
        }

        public bool IsOpen
        {
            [DebuggerStepThrough]
            get { return Model.IsOpen; }
        }

        public bool UpChecked
        {
            [DebuggerStepThrough]
            get { return Model.UpChecked; }
            set { Model.UpChecked = value; }
        }

        public bool DownChecked
        {
            [DebuggerStepThrough]
            get { return Model.DownChecked; }
            set { Model.DownChecked = value; }
        }

		public int WorkTime
		{
			[DebuggerStepThrough]
			get { return Model.WorkTime; }
			set { Model.WorkTime = value; }
		}
    }
}